import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MatGroupVO, MatGroupForm, MatGroupQuery } from '@/api/wmscloud/matGroup/types';


/**
 * 查询所有物料组
 * @returns {*}
 */

export const listAllGroup = (): AxiosPromise<MatGroupVO[]> => {
  return request({
    url: '/wmsCloud/matGroup/listAll',
    method: 'get'
  });
};
/**
 * 查询物料组列表
 * @param query
 * @returns {*}
 */

export const listMatGroup = (query?: MatGroupQuery): AxiosPromise<MatGroupVO[]> => {
  return request({
    url: '/wmsCloud/matGroup/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料组详细
 * @param groupId
 */
export const getMatGroup = (groupId: string | number): AxiosPromise<MatGroupVO> => {
  return request({
    url: '/wmsCloud/matGroup/' + groupId,
    method: 'get'
  });
};

/**
 * 新增物料组
 * @param data
 */
export const addMatGroup = (data: MatGroupForm) => {
  return request({
    url: '/wmsCloud/matGroup',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料组
 * @param data
 */
export const updateMatGroup = (data: MatGroupForm) => {
  return request({
    url: '/wmsCloud/matGroup',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料组
 * @param groupId
 */
export const delMatGroup = (groupId: string | number | Array<string | number>) => {
  return request({
    url: '/wmsCloud/matGroup/' + groupId,
    method: 'delete'
  });
};
